export const downloadText = (() => {
    let saveAs: (blob: Blob, filename: string) => void
    return async (text: string, filename: string) => {
        if (!saveAs) {
            saveAs = await new Promise((resolve, reject) => {
                const script = document.createElement('script')
                script.setAttribute('src', 'http://martsforever-demo.gitee.io/martsforever-assets/FileSaver.min.js')
                script.onload = () => resolve((window as any).saveAs)
                script.onerror = reject
                document.body.appendChild(script)
            })
        }
        saveAs(new Blob([text]), filename)
    }
})();